home *** CD-ROM | disk | FTP | other *** search
- /*
- ** MacWT -- a 3d game engine for the Macintosh
- ** © 1995, Bill Hayden and Nikol Software
- ** Free for non-commercial use - address questions to the e-mail address below
- **
- ** Mail: afn28988@freenet.ufl.edu (Bill Hayden)
- ** MacWT FTP site: ftp.circa.ufl.edu/pub/software/ufmug/mirrors/LocalSW/Hayden/
- ** WWW Page: http://grove.ufl.edu:80/~nikolsw
- **
- ** All of the above addresses are due to changes sometime in 1996, so stay tuned
- **
- ** based on wt, by Chris Laurel
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-
- #include <stdlib.h>
- #include <string.h>
- #include "wt.h"
- #include "error.h"
- #include "wtmem.h"
- #include "framebuf.h"
- #include "graphics.h"
- #include "StringUtils.h"
- #include "MacWT.h"
-
-
- static void SetShortMem(void *vptr, unsigned short c, unsigned long len);
-
-
-
- Framebuffer *NewFramebuffer(short width, short height)
- {
- Framebuffer *fb;
-
-
- fb = (Framebuffer *)wtmalloc(sizeof(Framebuffer));
-
- fb->fb_width = width;
- fb->fb_height = height;
-
- if (gTrueColor)
- {
- fb->pixels = nil;
- fb->pixels16 = GetFramebufferMemory();
- }
- else
- {
- fb->pixels = GetFramebufferMemory();
- fb->pixels16 = nil;
- }
-
- return fb;
- }
-
-
- void ClearFramebuffer(Framebuffer *fb)
- {
- short rb=fb->fb_rbytes;
- long iterations = fb->fb_height * rb;
-
- if (!gTrueColor)
- {
- Pixel *p=fb->pixels;
-
- if (gDrawFC)
- SetMem(p, 0xd2, iterations); // Reset fb to 8-bit cyan
- else
- {
- iterations >>= 1;
- SetMem(p, 0xfd, iterations); // Reset fb to lt/dk gray
- p += iterations;
- SetMem(p, 0xfa, iterations);
- }
- }
- else
- {
- Pixel16 *p=fb->pixels16;
-
- if (gDrawFC)
- SetShortMem(p, 0x001f, iterations); // Reset fb to 16-bit cyan
- else
- {
- iterations >>= 1;
- SetShortMem(p, 0x2108, iterations); // Reset fb to lt/dk gray
- p += iterations;
- SetShortMem(p, 0x6318, iterations);
- }
- }
- }
-
-
- static void SetShortMem(void *vptr, unsigned short c, unsigned long len)
- {
- short *ptr;
-
- ptr = (short *)vptr;
- while (len--) *ptr++ = c;
- }
-
-